package ServerImpl

import (
	"context"
	go_micro_user "go_micro_microservices/service/Interface"
	"strconv"
	"time"
)

type UserServiceImpl struct {
}

func (UserServiceImpl) GetUserInfo(ctx context.Context, in *go_micro_user.UserRequest, res *go_micro_user.UserResponse) error {
	time.Sleep(time.Second * 3)
	id := in.UserId
	if id <= 0 {
		id = 5
	}
	res.Code = 200
	res.Message = "获取用户" + strconv.Itoa(int(id)) + "号"
	var userList = make([]*go_micro_user.UserInfo, 0, id)
	for i := 1; i <= int(id); i++ {
		userList = append(userList, &go_micro_user.UserInfo{UserId: int32(i), UserName: "测试" + strconv.Itoa(i), Age: int32(i + 30)})
	}
	res.Data = userList
	return nil
}
